import config
import webapi
import util

def get_commit_data(commit_url,start_time,stop_time):
    api_data = webapi.get_commmit_data(commit_url, start_time, stop_time)
    data_df = util.clean_commit_data(api_data)
    return data_df


def main(config):
    for _ in config['repository_list']:
        commit_url = config['base_url']+'/repos{}/commits'.format(_)
        data = get_commit_data(commit_url ,config['plan']['start_time'], config['plan']['stop_time'])
        data.to_csv(config['data_path']['commit'].format(_.split('/')[-1])+'.csv')
        # data.to_excel(config['data_path']['commit'].format(_.split('/')[-1])+'.xlsx')

if __name__ == '__main__':
    _config = config.get_config()
    main(_config)